#!/bin/bash

# Function to get current Wi-Fi network name
get_current_wifi() {
    /usr/sbin/networksetup -getairportnetwork en0 | awk -F': ' '{print $2}' | tr -d '\r'
}

# Main execution starts here
wifi_name=$(get_current_wifi)

if [ -n "$wifi_name" ]; then
    echo "当前连接的 Wi-Fi 网络: $wifi_name"
else
    echo "当前没有连接 Wi-Fi"
fi
